<?php

namespace app\api\model\columns;

use think\Model;
use think\model\concern\SoftDelete;

class Sidebar extends Model
{
    use SoftDelete;

    /**
     * 定义软删除标记字段
     * @var string
     */
    protected $deleteTime = 'delete_at';

    /**
     * 定义时间戳字段名
     * @var string
     */
    protected $createTime = 'create_at';

    /**
     * 定义时间戳字段名
     * @var string
     */
    protected $updateTime = 'update_at';

    /**
     * 设置时间戳格式
     * @var string
     */
    protected $autoWriteTimestamp = 'datetime';

    /**
     * 定义全局查询范围
     * @var array
     */
    protected $globalScope = ['status','sort'];

    public function scopeStatus($query)
    {
        $query->where('status', 0);
    }

    public function scopeSort($query)
    {
        $query->order('sort', 'asc');
    }
}
